package com.lzw.breezeNovel.webApp.mapper.video;

import com.lzw.breezeNovel.model.entity.pojo.video.ShortComment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author 清风明月
 * @Package com.lzw.breezeNovel.webApp.mapper.video
 * @date 2025/3/23
 * @description 短视频的评论
 */
@Mapper
@SuppressWarnings("all")
public interface ShortCommentMapper {

    /**
     * 添加评论
     * @param shortComment
     */
    void insert(ShortComment shortComment);

    /**
     * 根据短文id查询评论数量
     * @param shortId
     * @return
     */
    Integer count(Long shortId);

    /**
     * 分页查询评论
     *
     * @param shortId
     * @param start
     * @param size
     * @param userId
     * @return
     */
    List<ShortComment> list(Long shortId, Integer start, Integer size, Long userId);

    /**
     * 更新点赞数量
     *
     * @param commentId
     * @param userId
     */
    @Update("update short_comment set like_count = like_count + 1 where id = #{commentId} and user_id = #{userId}")
    void updateLikeCountAdd(Long commentId, Long userId);

    /**
     * 更新点赞数量
     * @param commentId
     * @param userId
     */
    @Update("update short_comment set like_count = like_count - 1 where id = #{commentId} and user_id = #{userId}")
    void updateLikeCountSub(Long commentId, Long userId);
}
